package com.course.service.impl;

import com.course.entity.ResultBody;
import com.course.mapper.QuestionnaireMapper;
import com.course.service.QuestionnaireService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.server.DelegatingServerHttpResponse;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class QuestionnaireServiceImpl implements QuestionnaireService {
    @Autowired
    private QuestionnaireMapper questionnaireMapper;
    @Override
    public ResultBody addquestionnaire(String id,String key,String value,String coursepoint,String openquestion) {
        if(questionnaireMapper.addquestionnaire(id,key,value,coursepoint,openquestion)>0)
        {
            return new ResultBody(200,"回答成功",true);
        }
        else
            return new ResultBody(500,"回答失败",false);
    }
    @Override
    public ResultBody displayquestionnaire(Map<String, Object> map) {
        if(!questionnaireMapper.displayquestionnaire(map).isEmpty()) {
            return new ResultBody(200, "显示成功", questionnaireMapper.displayquestionnaire(map), questionnaireMapper.displayquestionnaire(map).size());
        }
        else if(questionnaireMapper.displayquestionnaire(map).isEmpty())
        {
            return new ResultBody(200,"暂无内容",questionnaireMapper.displayquestionnaire(map));
        }
        return new ResultBody(500,"显示失败",false);
    }

}
